package com.xcc.routerlib;

import android.content.Context;
import android.content.Intent;

import com.xcc.routerlib.utils.ActionUtils;

/**
 * ****************************************************
 * 作者 :: rookieCi<1056907550@qq.com>
 * ----------------------------------------------------
 * git :: https://gitee.com/rookieci
 * ----------------------------------------------------
 * 博客 :: http://blog.csdn.net/xcccicishuai
 * ----------------------------------------------------
 * 时间 :: 2019/5/28 Add by rookieCi
 * ----------------------------------------------------
 * 描述 :: CiRouter
 * ****************************************************
 */
public class CiRouter {
    private Context context;
    private Intent intent;

    public CiRouter(Context context) {
        this.context = context;
    }

    public void setIntent(Intent intent) {
        this.intent = intent;
    }

    public Intent getIntent() {
        return intent;
    }

    public void start() {
        if (intent == null || context == null) return;
        context.startActivity(intent);
    }

    public static class Builder {
        private CiRouter ciRouter;
        private ActionUtils actionUtils;

        public Builder(Context context) {
            ciRouter = new CiRouter(context);
            actionUtils = new ActionUtils(context);
        }

        public Builder setAction(String action) {
            actionUtils.setAction(action);
            return this;
        }

        public Builder setExtras(String extras) {
            actionUtils.setExtras(extras);
            return this;
        }

        public CiRouter create() {
            ciRouter.setIntent(actionUtils.resolve());
            return ciRouter;
        }
    }
}
